package com.bitdf.txing.order.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bitdf.txing.order.dao.OrderItemDao;
import com.bitdf.txing.order.entity.OrderEntity;
import com.bitdf.txing.order.entity.OrderItemEntity;
import com.bitdf.txing.order.entity.OrderReturnReasonEntity;
import com.bitdf.txing.order.service.OrderItemService;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.stereotype.Service;

import java.io.IOException;

//@RabbitListener(queues = {"hello-java-queue"})
@Service("orderItemService")
public class OrderItemServiceImpl extends ServiceImpl<OrderItemDao, OrderItemEntity> implements OrderItemService {

//    @Override
//    public PageUtils queryPage(Map<String, Object> params) {
//        IPage<OrderItemEntity> page = this.page(
//                new Query<OrderItemEntity>().getPage(params),
//                new QueryWrapper<OrderItemEntity>()
//        );
//
//        return new PageUtils(page);
//    }

//    @RabbitHandler
    public void recieveMessage(Message message, OrderReturnReasonEntity content, Channel channel){
//        System.out.println("接收到内容："+message+"类型—=》"+message.getClass());
        System.out.println("内容"+content);
        long deliveryTag = message.getMessageProperties().getDeliveryTag();
        try {
            if (deliveryTag%2==0){
                channel.basicAck(deliveryTag, false);
            }else {
                channel.basicNack(deliveryTag, false, true);
            }

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
//    @RabbitHandler
    public void recieveMessage2(OrderEntity content){
        System.out.println("内容"+content);
    }


}